require('../css/train.less');
require('../css/commom/basic.css');

document.ready(function(){

    let one=document.querySelector('.one')
    let endIcon=document.querySelector('.endIcon')
    let beginBox=document.querySelector('.beginBox')
    let sportTit=document.querySelector('.sportTit')
    let minuteTime=document.querySelector('.minuteTime')
    let userHead=document.querySelector('.userHead')
    let userName=document.querySelector('.userName')
    // 获取用户信息
    let user=JSON.parse(localStorage.getItem('user'))
    userHead.src=user.imgurl;
    console.log(user);
    userName.innerHTML=user.nickname;
    // 获取课程id
    let str=location.search;
    let obj=utils.getId(str);

    // 请求课程详情接口
    $http.get('/sports/courseDetail?id='+obj.id,function(res){
        console.log(res.data);
        sportTit.innerHTML=res.data.name;
        localStorage.setItem('videoData',JSON.stringify(res.data.fragments))
        minuteTime.innerHTML=res.data.time;
    })
    // 返回按钮
    one.addEventListener('click',function(){
        history.back()
    })
    // 跳转课程视频
    endIcon.addEventListener('click',function(){
        location.href='./details.html'
    })
    beginBox.addEventListener('click',function(){
        location.href='./details.html'
    })

})